﻿using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using FutureApp.Media;
using FutureApp.Users;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace FutureApp.Cms
{
    /// <summary>
    /// 文章
    /// </summary>
    [Table("Articles")]
    public class Article : FullAuditedEntity<Guid, User>, IPassivable
    {
        /// <summary>
        /// <see cref="Title"/> 的最大长度
        /// </summary>
        public const int MaxTitleLength = 50;

        /// <summary>
        /// <see cref="Title"/> 的最大长度
        /// </summary>
        public const int MaxContentLength = 4010;

        /// <summary>
        /// <see cref="Group"/> 的最大长度
        /// </summary>
        public const int MaxGroupLength = 20;

        /// <summary>
        /// <see cref="Url"/> 的最大长度
        /// </summary>
        public const int MaxUrlLength = 100;

        /// <summary>
        /// 标题
        /// </summary>
        [StringLength(MaxTitleLength)]
        public string Title { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        [StringLength(MaxContentLength)]
        public string Content { get; set; }

        /// <summary>
        /// 链接
        /// </summary>
        [StringLength(MaxUrlLength)]
        [DataType(DataType.Url)]
        public string Url { get; set; }

        /// <summary>
        /// 图片Id
        /// </summary>
        public Guid? PictureId { get; set; }

        /// <summary>
        /// 图片
        /// </summary>
        [ForeignKey(nameof(PictureId))]
        public Picture Picture { get; set; }

        /// <summary>
        /// 分类
        /// </summary>
        [StringLength(MaxGroupLength)]
        public string Group { get; set; }

        /// <summary>
        /// 激活/禁用
        /// </summary>
        public bool IsActive { get; set; }
    }
}
